#ifndef TOOL_PUSHBUTTON_H
#define TOOL_PUSHBUTTON_H

#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QMap>
#include <QJsonObject>

class ToolPushButton : public QWidget
{
    Q_OBJECT
public:
    explicit ToolPushButton(QWidget *parent = nullptr);
    ~ToolPushButton() override { qDebug() << "[ToolPushButton] ~ToolPushButton()"; }

    // 设置按钮命令映射，参数为json中flag5对象
    void setCommands(const QJsonObject &flag5Details);

    // 获取控件指针（方便外部操作）
    QWidget* getWidget();

signals:
    // 按钮被点击，携带对应命令字符串
    void commandTriggered(const QString &command);

private slots:
    void onButtonClicked();
    void onButtonPressed();
    void onButtonReleased();

private:
    void setupLayout(QWidget *widget);
    void connectSignals(QWidget *widget);

private:
    QWidget *ToolPtnWidget = nullptr;

    // Position按钮
    QPushButton *upButton = nullptr;
    QPushButton *downButton = nullptr;
    QPushButton *positionUpButton = nullptr;
    QPushButton *positionDownButton = nullptr;
    QPushButton *positionLeftButton = nullptr;
    QPushButton *positionRightButton = nullptr;

    // Rotation按钮
    QPushButton *LeftButton = nullptr;
    QPushButton *RightButton = nullptr;
    QPushButton *rotateLeftButton = nullptr;
    QPushButton *rotateRightButton = nullptr;
    QPushButton *rotateUpButton = nullptr;
    QPushButton *rotateDownButton = nullptr;

    QLabel *positionLabel = nullptr;
    QLabel *rotationLabel = nullptr;

    // 按钮名称对应命令映射
    QMap<QString, QString> commandMap;
    QString stopCommand;
};

#endif // TOOL_PUSHBUTTON_H
